from sqlmodel import Session
from entity.user import User
from orm.connet import engine


def findAll():
    with Session(engine) as session:
        users = session.query(User).all()
        return users
def find(id1):
    with Session(engine) as session:
        user = session.get(User,{"id":id1})
        return user
    

def update(id,name):
    with Session(engine) as session:
        user = session.get(User,{"id":id})
        if user:
            user.name = name
            session.commit()



def delete(id):
    with Session(engine) as session:
        user = session.get(User,{"id":id})
        if user:
            session.delete(user)
            session.commit()